package com.atguigu.gmall.product.service.impl;

import com.atguigu.gmall.product.mapper.BaseCategory1Mapper;
import com.atguigu.gmall.product.model.BaseCategory1;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: atguigu
 * @create: 2023-08-28 15:53
 */
@Service
public class BaseCategory1ServiceImpl extends ServiceImpl<BaseCategory1Mapper, BaseCategory1> implements com.atguigu.gmall.product.service.BaseCategory1Service {

    /**
     * 查询所有一级分类列表
     *
     * @return
     */
    @Override
    public List<BaseCategory1> getCategory1() {
        //1.构建查询条件对象
        //QueryWrapper<BaseCategory1> queryWrapper = new QueryWrapper<>();
        ////执行查询字段
        //queryWrapper.select("id", "name");


        LambdaQueryWrapper<BaseCategory1> queryWrapper1 = new LambdaQueryWrapper<>();
        queryWrapper1.select(BaseCategory1::getId, BaseCategory1::getName);
        //方式一：调用持久层实现查询
        //baseMapper.selectList(queryWrapper);
        //方式二：调用业务层实现查询
        return this.list(queryWrapper1);
    }
}
